import { ElementPlusResolverOptions } from "unplugin-vue-components/resolvers";

export const customStoreResolver = (options?: ElementPlusResolverOptions) => {
    return (name: string) => {
        if (!name.match(/^useStore[A-Z]/)) return;
        return { ...options, name, from: "@/store" };
    };
};

export const customApiResolver = (options?: ElementPlusResolverOptions) => {
    return (name: string) => {
        if (!name.match(/^(GET|POST|is|utils)[A-Z]/)) return;
        return { ...options, name, from: "@/request" };
    }
};

export const customHookResolver = (options?: ElementPlusResolverOptions) => {
    return (name: string) => {
        if (!name.match(/^use/)) return;
        return !name.match(/^useBusiness/) ? { ...options, name, from: "./hook" } : { ...options, name, from: "@/hooks" };
    }
};
